<template>
  <div id="query">
   <h3>您正在做的业务是：库存管理--安全库存配置管理--安全库存配置单审核</h3>
   <!--查询表单-->
   <el-form :inline="true" :model="searchObj" class="demo-form-inline">
     <el-form-item label="请选择I级分类">
	   <el-select v-model="searchObj.search_firstKindId" autocomplete="off">
	   	<el-option v-for="item in option1" :key="item.value" :label="item.label" :value="item.value"></el-option>
	   </el-select>
     </el-form-item><br/>
     <el-form-item label="请选择II级分类">
	   <el-select v-model="searchObj.search_secondKindId" autocomplete="off">
	   	 <el-option v-for="item in option2" :key="item.value" :label="item.label" :value="item.value"></el-option>
	   </el-select>
     </el-form-item><br/>
	 <el-form-item label="请选择III级分类">
	   <el-select v-model="searchObj.search_thirdKindId" autocomplete="off">
	   	 <el-option v-for="item in option3" :key="item.value" :label="item.label" :value="item.value"></el-option>
	   </el-select>
	 </el-form-item><br/>
	 <el-form-item label="请输入建档时间">
	   <el-date-picker
	     v-model="searchObj.search_registerTime1"
	     type="datetime"
	     value-format="yyyy-MM-dd HH:mm:ss"
	     format="MM/dd/yyyy HH:mm:ss"
	     placeholder="选择日期">
	   </el-date-picker>--
	   <el-date-picker
	     v-model="searchObj.search_registerTime2"
	     type="datetime"
	     value-format="yyyy-MM-dd HH:mm:ss"
	     format="MM/dd/yyyy HH:mm:ss"
	     placeholder="选择日期">
	   </el-date-picker>
	 </el-form-item>
     <el-form-item>
       <el-button type="primary" @click="selBtn">查询</el-button>
       <el-button type="warning" @click="">添加</el-button>
     </el-form-item>
   </el-form>
   
    <!--查询未复核的制定安全库存配置单的产品档案数据表格-->
    <el-table
      :data="storageCellAry"
      style="width: 100%">
      <el-table-column
        prop="storeId"
        label="库存编号"
        width="180">
      </el-table-column>
      <el-table-column
        prop="productId"
        label="产品编号"
        width="180">
      </el-table-column>
	  <el-table-column
	    prop="productName"
	    label="产品名称"
	    width="180">
	  </el-table-column>
	  <el-table-column
	    prop="firstKindName"
	    label="I级分类"
	    width="180">
	  </el-table-column>
	  <el-table-column
	    prop="secondKindName"
	    label="II级分类"
	    width="180">
	  </el-table-column>
	  <el-table-column
	    prop="thirdKindName"
	    label="III级分类"
	    width="180">
	  </el-table-column>
      <el-table-column
        prop="register"
        label="登记人"
        width="180">
      </el-table-column>
	  <el-table-column
	    prop="registerTime"
	    label="登记时间"
	    width="180">
	  </el-table-column>
      <!--操作列-->
      <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button
          size="mini"
		  type="primary"
		  round
		  icon="el-icon-edit"
          @click="recheckStorageCell(scope.$index,scope.row)">复核</el-button>
      </template>
    </el-table-column>
    </el-table>
	
    <!---分页组件-->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageNo"
      :page-sizes="pageSizeList"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
		
	<!-- 添加对话框 -->
	    <el-dialog title="制定安全库存配置单" :visible.sync="queryFormVisible" >
	      <el-form :model="queryRecheckAry">
	        <el-form-item label="产品名称" :label-width="formLabelWidth">
	          <el-input v-model="queryRecheckAry.productName"></el-input>
	        </el-form-item>
	        </el-form-item>
	        <el-form-item label="产品编号" :label-width="formLabelWidth">
	          <el-input v-model="queryRecheckAry.productId"></el-input>
	        </el-form-item>
	        <el-form-item label="库存报警下限数" :label-width="formLabelWidth">
	          <el-input v-model="queryRecheckAry.minAmount"></el-input>
	        </el-form-item>
	        <el-form-item label="库存报警上限数" :label-width="formLabelWidth">
	          <el-input v-model="queryRecheckAry.maxAmount"></el-input>
	        </el-form-item>
	        <el-form-item label="最大存储量" :label-width="formLabelWidth">
	          <el-input v-model="queryRecheckAry.maxCapacityAmount"></el-input>
	        </el-form-item>
	        <el-form-item label="设计人" :label-width="formLabelWidth">
	          <el-input v-model="queryRecheckAry.designer"></el-input>
	        </el-form-item>
			<el-form-item label="登记人" :label-width="formLabelWidth">
			  <el-input v-model="queryRecheckAry.register"></el-input>
			</el-form-item>
			<el-form-item label="登记时间" :label-width="formLabelWidth">
			  <el-date-picker
			    v-model="queryRecheckAry.registerTime"
			    type="datetime"
			    value-format="yyyy-MM-dd HH:mm:ss"
			    format="MM/dd/yyyy HH:mm:ss"
			    placeholder="选择日期">
			  </el-date-picker>
			</el-form-item>
			<el-form-item label="配置要求" :label-width="formLabelWidth">
			  <el-input v-model="queryRecheckAry.config"></el-input>
			</el-form-item>
	      </el-form>
	       <div slot="footer" class="dialog-footer">
	        <el-button @click="queryFormVisible = false">取 消</el-button>
	        <el-button type="primary" @click="saveRecheckStorageCell">复核</el-button>
	      </div>
	    </el-dialog>
	
  </div>
</template>

<script>

export default {
  name: 'query',
  data() {
    return  {
      storageCellAry: [],
      //当前页号
      pageNo: 1,
      //当前页大小
      pageSize: 5,
      //总记录数
      total: 0,
      //页大小列表
      pageSizeList: [2, 5, 10, 20],
      //查询条件对象
      searchObj: {
        search_firstKindId:"",
		search_secondKindId:"",
		search_thirdKindId:"",
		search_registerTime1:"",
		search_registerTime2:""
      },
	  //添加对话框的显示
	  queryFormVisible: false,
	  //添加表单的对象
	  makeForm: {},
	  //lable宽度
	  formLabelWidth: '120px',
	  option1: [{
	    	 value: '01',
	    	 label: '电子'
	    }],
	    option2: [{
	    	 value: '01',
	    	 label: '电子/计算机'
	    }],
	    option3: [{
	    	 value: '01',
	    	 label: '电子/计算机/服务器'
	    }],
		//定义一个数组
		queryRecheckAry: {}
    }
  },
  methods: {
/* 	//显示添加对话框
	showmakeDialog() {
		//清空绑定对象
		this.makeForm = {}
		//显示对话框
		this.makeFormVisible = true
	}, */
    //表单查询
    search() {
		//查询
		this.pageNo = 1
		this.storageCellPage()
    },
    //页大小改变
    handleSizeChange(val) {
        this.pageSize = val
        this.storageCellPage()
    },
    //页号改变
    handleCurrentChange(val) {
		this.pageNo = val
		// 重新查询
		this.storageCellPage()
    },
    //分页查询班级信息
    async storageCellPage() {
		// 用es6的解构函数
		const {data: res} = await this.$http.post
		(`/design/storage/storageCellQuery/${this.pageNo}/${this.pageSize}`,this.searchObj)
		this.storageCellAry = res.rows
		this.total = res.total
    },
	async recheckStorageCell(index,row){
		//显示对话框
		this.queryFormVisible = true
		this.$http.post(`/design/storage/storageCellGetId/${row.id}`).then((res)=>{
			this.queryRecheckAry = res.data
		})
	},
	async saveRecheckStorageCell(){
		this.$http.post(`/design/storage/storageCellReviewPassed`,this.queryRecheckAry).then((res)=>{
			//关闭对话框
			this.queryFormVisible = false
			// 消息提示
			this.$message('复核成功')
			// 刷新表格
			this.storageCellPage()
		})
	},
	selBtn(){
		this.storageCellPage()
		}
	},
	created() {
		this.storageCellPage()
  }
}
</script>

<style>

</style>
